home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd25.zip
/
MUTT2.ZIP
/
TAGS.MUT
< prev
next >
Wrap
Text File
|
1992-11-09
|
2KB
|
104 lines
;; Lookup stuff in a tags file
;; To create a tags file in:
;; current directory: ctags -xtw files.[ch] >Tags
;; a subtree: find . -name '*.[ch]' -print | xargs ctags -xtw >Tags
;; Keep the tags file in the directory it is created in
;; C Durland Public Domain
(include me2.h)
(string tags-path file-name text)
(int tag-buffer)
(bool loaded-tags)
(defun
MAIN
{
(bind-to-key "goto-tag" "M-.") ;; GNU binding
}
)
(defun
lookup-tag (string tag) HIDDEN ; search the tags buffer for a tag
{
(bool s)(int cb)
(if (not loaded-tags) { (msg "No tags! Run select-tag-file.")(done) })
(msg "Looking for tag ...")
(s TRUE)
(cb (current-buffer))
(current-buffer tag-buffer)(beginning-of-buffer)
(if (re-search-forward (concat '^' tag '\ '))
{
(looking-at '\ *\d+ \([^ ]+\)\ +\(.+\)')
(file-name (get-matched '\1'))
(text (get-matched '\2'))
}
{ (msg tag " not found.")(s FALSE) }
)
(current-buffer cb)
s
}
get-tag-name HIDDEN
{
(string tag)
(if (== "" (tag (ask "Tag to look for: ")))
{ (looking-at '\w+')(get-matched '&') }
tag
)
}
goto-tag
{
(string tag)
(tag (get-tag-name))
(if (lookup-tag tag)
{
(visit-file (concat tags-path "/" file-name))
(if (search-forward text)
{ (arg-prefix 1)(reposition-window) } ; move to top of screen
(msg "Tag file is out of date.")
)
})
}
where-is-tag
{
(string tag)
(tag (get-tag-name))
(if (lookup-tag tag)
(msg tag " is in " tags-path "/" file-name))
}
select-tag-file MAIN
{
(int cb)
(string tags-file)
(loaded-tags FALSE)
(tags-path (complete CC_FNAME "DIRECTORY tags file is in: "))
(tags-file (concat tags-path "/Tags"))
(if (not (file-exists tags-file))
{ (msg "No such tags file: " tags-file)(done) })
(cb (current-buffer))
(if (== -2 (tag-buffer (attached-buffer "*TAGS*")))
(tag-buffer (create-buffer "*TAGS*" BFHooHum)))
(current-buffer tag-buffer)
(clear-buffer)
(read-file tags-file)
(current-buffer cb)
(loaded-tags TRUE)
(msg "Loaded tags")
}
)